package com.itm.lqm.service;

import java.util.List;


import com.itm.lqm.dao.GradeDao;
import com.itm.lqm.entity.Grade;


public class GradeService {
	GradeDao gd=new GradeDao();
	//查询成绩
	public List<Grade> findGradeAll(){
		List<Grade> list=gd.findGradeAll();
		return list;
	}
	
	//根据gid查询成绩
		public Grade findGradeByGid(int gid){
			Grade g=gd.findGradeByGid(gid);
			return g;
		}	
		
		public Grade findGradeBygid(int gid){
			Grade g=gd.findGradeBygid(gid);
			return g;
		}
		public List<Grade> findGradeByClass(String clas){
			List<Grade> list=gd.findGradeByClass(clas);
			return list;
		}
		
		
	//添加成绩
	public boolean addGrade(Grade g){
		if(!gd.isExistGid((g.getGid()))){
			gd.addGrade(g);
			return true;
		}else{
			System.out.println("此成绩已存在");
			return false;
		}
	}
	
	//
	//删除课程
	public boolean deleteGradeByGid(int gid){
//				if(gd.isExistGid(gid)){
//					gd.deleteGradeByGid(gid);
//					return true;
//				}else{
//					return false;
//				}
		gd.deleteGradeByGid(gid);
		return true;
			}
			//修改课程
	public boolean updateGrade(Grade g){
				if(gd.isExistGid(g.getGid())){
					gd.updateGrade(g);
					return true;
				}else{
					return false;
				}
			}
			

}
